package com.example.administrator.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.example.administrator.myapplication.adapter.MyAdapter;

/**
 * Created by Administrator on 2020/11/26.
 */

public class CitySelectActivity extends Activity{
    String[] citys = {"长沙市","株洲市","湘潭市","岳阳市","郴州市","衡阳市","娄底市"};
    private ListView cityListView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_city);
        initView();
        initData();
        initEvent();
    }
    private void initView(){
        cityListView = findViewById(R.id.city_listview);
        cityListView.setAdapter(new MyAdapter(CitySelectActivity.this,citys));
    }
    private void initData(){

    }
    private void initEvent(){
        cityListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent = new Intent();
                intent.putExtra("data",citys[i]);
                setResult(1,intent);
                finish();
            }
        });
    }


    }

